#include "includes.h"
#include "structs.h"

/* file: gengp.c
 * date: Feb 17th
 * author: cong
 * 
 * Generate an .gp file from either vfile + efile or
 * .mis (dimacs format) for input of the gpmetis 
 * program to partition the graph.
 * 
 * You can use the graphchk coming with METIS to
 * verify the correctness of the .gp file. gengp
 * will not do that for you.
 * 
 * Usage: gengp --dimacs graphfile
 *        gengp --vefile vfile efile
 *        
 */
const char *argp_program_version="gengp 1.0";
const char *argp_program_bug_address="cgsdfc@126.com";

struct argp_option gengp_options[]={
        {
                .name="dimacs",
                .key="d",
                .arg=0,
                .flags=0,
                .doc="whether to use dimacs file as input\n"
        },
        {
                .name="vefile",
                .key="v",
                .arg=0,
                .flags=0,
                .doc="whether to use vfile + efile as input\n"
        }
        {0}
};
error_t gengp_parser(int key,char *arg,struct argp_state *state);


struct argp gengp_argp = 
{
        .options=gengp_options,
        .parser=gengp_parser,
        .args_doc="Usage gengp --dimacs graphfile\n"
                "gengp --vefile vfile efile",
        .doc="gengp: generates the input file for gpmetis to partition"
};

enum input_src { DIMACS,VEFILE };
int INPUT_SRC=-1;

error_t gengp_parser(int key,char *arg,struct argp_state *state){
        switch(key) {
                case 'd':
                        INPUT_SRC=DIMACS;
                        break; 
                case 'v':
                        INPUT_SRC=VEFILE;
                        break;
                default:
                        return ARGP_ERR_UNKNOWN;
        }
        return 0;
}
#ifdef _DIMACS_
int main(int ac, char**av)
{
        FILE *vfile = fopen("simple.v", "r");
        FILE *efile = fopen("simple.e", "r");
        zlog_init(ZLOG_CONF_PATH);
        char *dimacs_path="/home/cong/ans/mis/frb30-15-mis/frb30-15-5.mis";
        char *dimacs_gpmetis="test-dimacs.gp";

        verfile2gpmetis("simple.v","simple.e",2,"simple.gp");
        /* dimacs2gpmetis(dimacs_path,dimacs_gpmetis); */
}
#endif

